Skip to content

fix: preserve guarded sample lifecycle - #1466

Merged
Jammy2211 merged 1 commit into
mainfrom
fix/guarded-sample-lifecycle
Aug 11, 2026
Merged

fix: preserve guarded sample lifecycle#1466
Jammy2211 merged 1 commit into
mainfrom
fix/guarded-sample-lifecycle

Conversation

@Jammy2211

Copy link
Copy Markdown
Collaborator

Summary

Keep the new model-parameter guards, while making every stored-sample consumer treat guard failures as rejected historical points instead of fatal infrastructure errors.

This addresses the two independent regressions behind the blocked nightlies:

Changes

  • Preserve samples.model, the concrete samples class, and samples_info when test-mode recovery replaces a rejected final sample.
  • For instance materialization, fall back from an invalid maximum-likelihood historical point to the next valid point.
  • Retry PDF draws rejected by FitException, with a bounded attempt limit and a clear SamplesException if no valid point exists.
  • Skip FitException-invalid points in weighted aggregator replay while keeping samples and weights aligned.
  • Reconstruct aggregator points through the stored model so shared factor-graph children remain intact.
  • Catch only FitException; unrelated programming errors still propagate.

The PyAutoGalaxy guards themselves are unchanged.

Regression coverage

Adds coverage for:

  • factor-graph per-analysis children
  • preservation of sampler subtype and metadata
  • invalid historical maximum-likelihood fallback
  • bounded PDF redraw and all-invalid failure
  • weighted aggregator filtering and weight alignment
  • shared factor-graph children during aggregator replay
  • propagation of non-FitException errors

Validation

  • Focused regression suite: 48 passed
  • Full PyAutoFit suite: 1723 passed, 2 skipped
  • git diff --check: clean

@Jammy2211
Jammy2211 marked this pull request as ready for review August 11, 2026 16:46
@Jammy2211
Jammy2211 merged commit b499d43 into main Aug 11, 2026
3 checks passed
@Jammy2211
Jammy2211 deleted the fix/guarded-sample-lifecycle branch August 25, 2026 18:14
Jammy2211 pushed a commit to trexfr-ops/PyAutoFit that referenced this pull request Aug 27, 2026
…PyAutoLabs#1486)

`Samples.instances` and the shared `to_instance` decorator materialized
stored samples with no `FitException` recovery, so results written before
a model's constructor validation tightened raise from deep inside instance
construction (PyAutoFit#1486; workspace half shipped as
autogalaxy_workspace#210).

- `to_instance` gains a per-method recovery policy: `max_log_posterior`
  falls back to the next valid stored sample (mirroring the PyAutoLabs#1466
  `max_log_likelihood` guard via a shared helper); `from_sample_index`
  and the marginalized methods raise a typed `SamplesException` chained
  to the rejection, since they have no valid stored sample to substitute.
- `Samples.instances` skips rejected stored samples with a warning,
  reusing `valid_sample_instance_pairs` (PyAutoLabs#1470).
- The mode-1 rejected-final-sample hook and the updater's samples-save
  guard catch the new wrapped type.

BREAKING: reconstruction failures from `to_instance`-decorated methods
now surface as `SamplesException` instead of `ModelParameterException`.

Co-Authored-By: Claude Fable 5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant